package com.aaa.controller;
import com.aaa.service.T_CyglService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/cygl/")
public class T_CyglController {
    @Autowired
    private T_CyglService cyglService;

    @RequestMapping("toList")
    public String toList(){
        return "examination/examination";
    }
    @RequestMapping("list")
    @ResponseBody
    public Object list(@RequestBody Map map){
        List<Map> data=cyglService.selectAll(map);
        Integer total=cyglService.getCount(map);
        Map map1=new HashMap();
        map1.put("data",data);
        map1.put("total",total);
        return map1;
    }
    /**
     * 删除事件
     * @param id
     * @return
     */
    @RequestMapping("del/{id}")
    @ResponseBody
    public  Integer del(@PathVariable Integer id){
        return cyglService.del(id);
    }
    /**
     * 下拉框数据
     * @return
     */
    @RequestMapping("infoList")
    @ResponseBody
    public List<Map> infoList(){
        return cyglService.infoList();
    }

    /**
     * 编辑事件
     * @param map
     * @return
     */
    @RequestMapping("upd")
    @ResponseBody
    public Integer upd(@RequestBody Map map){
        return cyglService.upd(map);
    }

    /**
     * 生成账号 发邮件  状态改成 待考试
     * @param map
     * @return
     */
    @RequestMapping("sendemail")
    @ResponseBody
    public Integer send(@RequestBody Map map){
        //System.out.println(map.get("id"));
        //System.out.println(map.get("email"));
        //随机生成用户  发邮件
        int addEaxmPerson=cyglService.addEaxmPerson(map);
        return addEaxmPerson;
    }

    /**
     * 查询每种题目类型有多少题
     * @return
     */
    @RequestMapping("max")
    @ResponseBody
    public Map max(){
        return cyglService.max();
    }
    @RequestMapping("add")
    @ResponseBody
    public int add(@RequestBody Map map){
        return cyglService.add(map);
    }
}
